//
//  MYGAcademicDetailFooterCell.swift
//  MYDoctor
//
//  Created by chenjs on 2024/6/1.
//

import UIKit
import QMUIKit

class MYGAcademicDetailFooterCell: UITableViewCell {
    var model : MYGAcademicDetailFooterCellModel? {
        didSet {
            guard let item = model else {return}

            timeLabel.text = item.time
            let name = item.models.joined(separator: ",")
            let nameStr = name.replacingOccurrences(of: ",", with: "\n")
            let str = nameStr.replacingOccurrences(of: "/", with: "")
            titleLab.text = str.replacingOccurrences(of: "()", with: "")
        }
        
        
    }
    // MARK: - init
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        selectionStyle = .none
        contentView.backgroundColor = .white
        configUI()
       

    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    func configUI() {
        contentView.addSubview(backView)
        backView.addSubview(timeLabel)
        backView.addSubview(line)
        backView.addSubview(titleLab)
        
        backView.snp.makeConstraints { make in
            make.left.right.equalToSuperview().inset(20)
            make.top.bottom.equalToSuperview()
        }
        
        timeLabel.snp.makeConstraints { make in
            make.top.equalTo(10)
            make.left.equalToSuperview().inset(20)
            make.height.equalTo(31.5)
        }
        
        line.snp.makeConstraints { make in
            make.left.equalTo(timeLabel)
            make.top.equalTo(timeLabel.snp.bottom)
            make.height.equalTo(1.5)
            make.right.equalToSuperview().inset(20)
        }
        
        titleLab.snp.makeConstraints { make in
            make.right.left.equalToSuperview().inset(20)
            make.top.equalTo(line.snp.bottom).offset(10)
        }
        
        backView.addBordorLine(top: false, right: true, bottom: false, left: true, color: UIColor.init(hexString: "f6f6f6"), width: 2)
//        backView.addCorner(radius: 5)
    }
    
    private lazy var backView:UIView = {
        let view = UIView()
        view.backgroundColor = .white
        return view
    }()
    private lazy var timeLabel: QMUILabel = {
        let label = QMUILabel()
        label.font = .regular(15)
        label.textColor = .rgba(255, 255, 255, 1)
        label.backgroundColor = .rgba(59, 55, 222, 1)
        label.layer.cornerRadius = 5
        label.layer.masksToBounds = true
        label.layer.maskedCorners = [.layerMinXMinYCorner,.layerMaxXMinYCorner]
        label.contentEdgeInsets = UIEdgeInsets(inset: 5)
        return label
    }()
    
    private lazy var line:UIView = {
        let line = UIView()
        line.backgroundColor = .rgba(59, 55, 222, 1)
        return line
    }()
    private lazy var titleLab: UILabel = {
        let label = UILabel()
        label.font = .regular(12)
        label.textColor = .rgba(97, 97, 97, 1)
        label.numberOfLines = 0
        return label
    }()
  
}
